import re

print(re.search(r'[0-9]', 'i love 123'))
print(re.search(r'[2-9]', 'i love 123'))
print(re.search(r'ab{3}c', 'abbbc'))
print(re.search(r'b{3}', 'i love 123b333'))
print(re.search(r'b{3,10}', 'bbb33333'))


# 匹配ip
print('------ip------')
ipPattern = r'[01]\d\d|2[0-4]\d|25[0-5]\.'
print(re.search(ipPattern,'255.'))

ipPattern2 = r'(([01]\d\d|2[0-4]\d|25[0-5])\.){3}[01]\d\d|2[0-4]\d|25[0-5]\.'
print(re.search(ipPattern2,'192.192.192.123'))

#最终版
ipPattern3 = r'(([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])\.){3}[01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5]\.'
print(re.search(ipPattern3,'192.192.1.1'))


